package com.bwie.bargain.controller;

import java.util.Arrays;
import java.util.Map;

import com.bwie.bargain.service.BargainService;
import com.bwie.bargain.vo.BargainVo;
import com.bwie.bargain.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bwie.bargain.entity.TakenotesEntity;
import com.bwie.bargain.service.TakenotesService;
import com.bwie.miaosha.common.utils.PageUtils;
import com.bwie.miaosha.common.utils.R;



/**
 * 
 *
 * @author HouDing
 * @email 1398853436@qq.com
 * @date 2022-03-09 20:02:51
 */
@RestController
@RequestMapping("bargain/takenotes")
public class TakenotesController {
    @Autowired
    private TakenotesService takenotesService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = takenotesService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{notesId}")
    public R info(@PathVariable("notesId") Long notesId){
		TakenotesEntity takenotes = takenotesService.getById(notesId);

        return R.ok().put("takenotes", takenotes);
    }

    @RequestMapping("/checkHelpId")
    public R checkUid(@RequestParam("helpId") Long helpId){
        TakenotesEntity te = takenotesService.findByHelpId(helpId);
        return R.ok().put("te", te);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody TakenotesEntity takenotes){
		takenotesService.save(takenotes);

        return R.ok();
    }


    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody TakenotesEntity takenotes){
		takenotesService.updateById(takenotes);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] notesIds){
		takenotesService.removeByIds(Arrays.asList(notesIds));

        return R.ok();
    }

}
